package com.heima.wemedia.controller;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDTO;
import com.heima.model.wemedia.dtos.WmNewsPageReqDTO;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
public class WmNewsController {
    @Autowired
    private WmNewsService wmNewsService;
    @PostMapping("/api/v1/news/list")
    public PageResponseResult findList(@RequestBody WmNewsPageReqDTO wmNewsPageReqDTO)
    {
        return wmNewsService.findList(wmNewsPageReqDTO);
    }
    @GetMapping("/api/v1/news/one/{id}")
    public ResponseResult findWmNewsById(@PathVariable("id") Integer id){
        return wmNewsService.findWmNewsById(id);
    }
    @GetMapping("/api/v1/news/del_news/{id}")
    public ResponseResult deleteNewById(@PathVariable("id") Integer id){
        return wmNewsService.deleteNewById(id);
    }
    @PostMapping("/api/v1/news/down_or_up")
    public ResponseResult  downOrUp(@RequestBody WmNewsDTO dto){

        return wmNewsService.downOrUp(dto);
    }

//    PostMapping("/api/v1/news/submit")
//    public ResponseResult submitNews(@RequestBody WmNewsDTO wmNewsDTO){
//
//    }

}
